﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace _06_资源字典
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            // 代码中动态设置资源字典的值
            Resources["DefaultForeground"] = new SolidColorBrush(Colors.Red);
            // 从资源字典中获得资源的值
            var solidColor = Application.Current.FindResource("DefaultForeground") as SolidColorBrush;
            var style = Application.Current.FindResource("DefaultButtonStyle") as Style;
            // 动态设置资源
            btn1.Style = style;
            btn1.Foreground = solidColor;
        }
    }
}
